<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<WebClient.Models.ViewModels.GroupViewModel>" %>
<%@ Import Namespace="WebClient.Helpers" %>

<div class="AdminPageText">
List Of Orders
</div>
<% using (Html.BeginForm("UpdateOrders", "Admin", FormMethod.Post, new { id = "MySubmitForm" })){ %>
<table class="Grid" cellpadding="0" cellspacing="0">
	<thead>
		<tr>
			<th>ID</th>
            <th>OrderDate</th>
            <th>ShipDate</th>
			<th>IsVerified</th>
			<th>IsShipped</th>
			<th></th>
            <th></th>
            <th></th>
			<th></th>
		</tr>
	</thead>
	<% for (int i=0; i<Model.OrdersModel.GetModel.LstObjModel.Count; i++){
		if (i % 2 != 0) {%>
		<tr class="Row" id="row-<%= Model.OrdersModel.GetModel.LstObjModel[i].ID %>">
		<% }
		else { %>
		<tr class="AlternatingRow" id="row-<%= Model.OrdersModel.GetModel.LstObjModel[i].ID %>">
		<% } %>
		<% if (Model.OrdersModel.GetModel.LstObjModel[i].ID == Model.OrdersModel.EditModel.ID){ %>
            <td><span style=""><%= Model.OrdersModel.GetModel.LstObjModel[i].ID %></span></td>
			<td><span style=""><%= Model.OrdersModel.GetModel.LstObjModel[i].OrderDate %></span></td>
            <td>
                <input type="text" name="Orders_ShipDate" id="Orders_ShipDate" value="<%= Model.OrdersModel.GetModel.LstObjModel[i].ShipDate %>" />
            </td>
            <td><span style=""><%= Html.CheckBox("Orders_IsVerified", Model.OrdersModel.GetModel.LstObjModel[i].IsVerified)%></span></td>
			<td><span style=""><%= Html.CheckBox("Orders_IsShipped", Model.OrdersModel.GetModel.LstObjModel[i].IsShipped)%></span></td>
			<td>
				<a href="#" onclick="submitForm();">
					<span style="color: Blue; text-decoration: underline">Update</span>
				</a>
				&nbsp;
				<%= Html.Hidden("Orders_CurrentPage", Model.OrdersModel.GetModel.CurrentPage) %>
				<%= Html.Hidden("Orders_ID", Model.OrdersModel.GetModel.LstObjModel[i].ID)%>
                <%= Html.Hidden("Orders_IDRestaurant", Model.RestaurantModel.GetModel.LstObjModel[0].ID)%>
                <a href="../../Admin/CancelEditingOrders?idrestaurant=<%= Model.RestaurantModel.GetModel.LstObjModel[0].ID %>&page=<%= Model.OrdersModel.GetModel.CurrentPage %>">
					<span style="color: Blue; text-decoration: underline">Cancel</span>
				</a>
			</td>
            <td>
                <a href="../../Admin/SelectOrderDetailByIDOrder?idorder=<%= Model.OrdersModel.GetModel.LstObjModel[i].ID %>&idrestaurant=<%= Model.RestaurantModel.GetModel.LstObjModel[0].ID %>">
					<span style="color: Blue; text-decoration: underline">Select</span>
				</a>
			</td>
			<td>
				<a href="../../Admin/DeleteOrders?id=<%= Model.OrdersModel.GetModel.LstObjModel[i].ID %>&idrestaurant=<%= Model.RestaurantModel.GetModel.LstObjModel[0].ID %>&page=<%= Model.OrdersModel.GetModel.CurrentPage %>" onclick="return confirm('Are you sure you want to Delete it? This action cannot be undone.');">Delete</a>
			</td>
		<% }else{ %>
            <td><span style=""><%= Model.OrdersModel.GetModel.LstObjModel[i].ID %></span></td>
			<td><span style=""><%= Model.OrdersModel.GetModel.LstObjModel[i].OrderDate %></span></td>
            <td><span style=""><%= Model.OrdersModel.GetModel.LstObjModel[i].ShipDate %></span></td>
			<td><span style=""><%= Html.CheckBox("Orders_IsVerified2", Model.OrdersModel.GetModel.LstObjModel[i].IsVerified, new { disabled = "disabled" })%></span></td>
			<td><span style=""><%= Html.CheckBox("Orders_IsShipped2", Model.OrdersModel.GetModel.LstObjModel[i].IsShipped, new { disabled = "disabled" })%></span></td>
			<td>
				<a href="../../Admin/EditOrders?id=<%= Model.OrdersModel.GetModel.LstObjModel[i].ID %>&idrestaurant=<%= Model.RestaurantModel.GetModel.LstObjModel[0].ID %>&page=<%= Model.OrdersModel.GetModel.CurrentPage %>">
					<span style="color: Blue; text-decoration: underline">Edit</span>
				</a>
			</td>
            <td>
                <a href="../../Admin/SelectOrderDetailByIDOrder?idorder=<%= Model.OrdersModel.GetModel.LstObjModel[i].ID %>&idrestaurant=<%= Model.RestaurantModel.GetModel.LstObjModel[0].ID %>">
					<span style="color: Blue; text-decoration: underline">Select</span>
				</a>
			</td>
			<td>
				<a href="../../Admin/DeleteOrders?id=<%= Model.OrdersModel.GetModel.LstObjModel[i].ID %>&idrestaurant=<%= Model.RestaurantModel.GetModel.LstObjModel[0].ID %>&page=<%= Model.OrdersModel.GetModel.CurrentPage %>" onclick="return confirm('Are you sure you want to Delete it? This action cannot be undone.');">Delete</a>
			</td>
		<% } %>
		</tr>
	<% } %>  
</table>
<% } %>
